package com.test.demo.controller;

import com.test.demo.model.Company;
import com.test.demo.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;


/**
 * 编写者：郝嘉
 * 编写时间：2019-05-27
 * 模块功能描述：公司表的增删改查
 */
@RestController(value = "/Company")
public class CompanyController {
    @Autowired
    private CompanyService companyService;

    @CrossOrigin
    @RequestMapping(value = "/getCIsBegin")
    public List<Company> getCIsBegin(){
        System.out.println("调用公司全部类型的接口");
        List<Company> companyList = companyService.getCIsBegin();
        return companyList;

    }

    @CrossOrigin
    @RequestMapping(value = "/getAllh")
    public List<Company> getAllh(){
        System.out.println("调用公司全部信息的方法");
        return companyService.getAllh();

    }

    @CrossOrigin
    @RequestMapping(value = "/getOne1")
    public Company getOne1(Integer cid) {
        return companyService.selectByPrimaryKey1(cid);
    }


    @CrossOrigin
    @RequestMapping(value = "/delCompany",method = RequestMethod.GET)
    public int delCompany(Integer cid){
        System.out.println("调用公司全部信息的方法");
        return companyService.delCompany(cid);
    }
    @CrossOrigin
    @RequestMapping(value = "/addCompany",method = RequestMethod.PUT)
    public int addCompany(@RequestBody Company companymodel){
        if (companymodel != null){

        }else {

        }
        return companyService.insertCompany(companymodel);
    }

    @CrossOrigin
    @RequestMapping(value = "/updateCompany",method = RequestMethod.PUT)
    public int updateCompany(@RequestBody Company companymodel){
        return companyService.updateCompany(companymodel);
    }
}
